Command line utilities

last modified

2024–9–27

File name parts with basename

Filename without path:

FILENAME=`basename /usr/bin/sort`

sets FILENAME to sort.

Filename without path and specified extension:

FILENAME=`basename include/stdio.h .h`

sets FILENAME to stdio.

String formatting with printf

E.g. print arguments as shell-escaped string:

printf "%q " $*

Temporary file or directory with mktemp

The (empty) file or directory is created, with a random name in the temporary directory.

TMPFILE=`mktemp`
TMPDIR=`mktemp -d`

Follow file from start

tail -n +1 -f
tail -n +1 -f | cmd

Run command preventing sleep

systemd-inhibit <command>

Convert scans to PDF

convert <images> <output>.pdf

The print size can be controlled via -density 150, uniform size in pixels induced via -extent "2476x3503" -gravity Center.


TODO: tr, sed, awk, jq, regex-rename